<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Sites</title>
<link href="/css/admin.css" rel="stylesheet" type="text/css" />
<script src="/js/jquery-1.5.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
	$(function () {
		$('.commonTable tr').hover(function () {
			$(this).css('background-color', '#ffffae');
		},
        function () {
        	$(this).css('background-color', '#FFFFFF');
        });
    });
	function addart(){
		window.location = "/cms/addart/<?=$cid?>";
	}
	function editart(aid){
		window.location = "/cms/editart/" + aid;
	}
	function delart(aid){
		if(confirm('确定删除？'))
			window.location = "/cms/delart/<?=$cid?>/" + aid;
	}
	function chkall(obj){
		$("input:checkbox[name='chk']").attr('checked', obj.checked);
	}
	function goPage(p){
		window.location = "/cms/articles/<?=$cid?>/" + p;
	}
	function copyart(){
		var sel = '';
		$("input:checkbox[name='chk']:checked").each(function(){ 
			sel += "," + $(this).val();
		});
		if(sel == '')
			alert('请选择要复制的文档!');
		else
			window.open('/cms/choosecol/<?=$sid?>/multi','请选择栏目','width=350,height=300,left=' + (screen.availWidth - 350) / 2 + ',top=' + (screen.availHeight - 300) / 2);
	}
	function setcol(parm){
		var sel = '';
		$("input:checkbox[name='chk']:checked").each(function(){ 
			sel += "," + $(this).val();
		});
		$.post("/cms/copyart", { 			
			aid: sel, 
			cid: parm
			},function (data) {
				if(data == 'ok')
					alert('复制成功!');
				else
					alert(data);
					//alert('复制失败!');
		});
	}
</script>
</head>
<body>
	<div class="listTitle">文档列表:&nbsp;<?=$cname?></div>
	<div class="btnDiv"><input  type="button" value="添加文档" onclick="addart()" />&nbsp;&nbsp;<input type="button" value="复制到其他栏目" onclick="copyart()" /></div>
	<div><table class="commonTable" width="100%" cellspacing="0" cellpadding="5" >
	    <tr>
	    	<th><input id="ckall" name="ckall" type="checkbox" id="chk_All" onclick="chkall(this)"></th>
		    <th>标题</th>
			<th>类型</th>
			<th>更新时间</th>
			<th>发布人</th>
			<th>是否显示</th>
			<th>权重</th>
			<th>状态</th>
		    <th width="60" >
		    </th>
	    </tr>
		<?php $n=0;
			foreach ($query->result_array() as $row){ $n++;?>
			<tr>
			<td><input type="checkbox" id="chk_<?=$n?>" name="chk" value="<?=$row['aid']?>" /></td>
			<td><a href="javascript:editart('<?=$row['aid']?>')"><?=$row['title']?></a></td>
			<td><?php switch ($row['atype']){
						case '0':
							echo('文档');
							break;
						case '1':
							echo('附件');
							break;
						case '2':
							echo('超链接');
							break;
						} ?></td>
			<td><?=$row['updatetime']?></td>
			<td><?=$row['createby']?></td>
			<td><?php if($row['display']==0)
						echo("<font color='#009933'>显示</font>");
					  else 
					    echo("<font color='#D14836'>隐藏</font>");
			    ?></td>
			<td><?=$row['sortno']?></td>
			<td><?php if($row['astatus']==0)
						echo("<font color='#D14836'>待审</font>");
					  else 
					    echo("<font color='#009933'>已审</font>");
			    ?></td>
			<td><?php 
			$editable = false;
			if($rlevel > 0)
				$editable = true;
			else if($row['astatus']== 0 && $row['createby'] == $userid){
				$editable = true;
			}
		 	if($editable){?><a href="javascript:editart('<?=$row['aid']?>')">编辑</a>&nbsp;<a href="javascript:delart('<?=$row['aid']?>') ">删除</a><?php } else{?><font color="#dcdcdc">编辑&nbsp;删除</font><?php }?></td>
			</tr>
		<?php }?>
	</table></div>
	<?php echo($pager);?>
</body>
</html>